<template>
  <div>
    <el-button @click="closeDrawer()" size="small" type="primary">导入模板下载</el-button>
    <div style="margin-top:20px;"></div>
    <!-- <UploadFile
      action-url="/orderGoods/productUpload"
      :initial-value="fileList"
      @change="successHandler"
      :params="params"
      :limit='1'
    >上传</UploadFile> -->
    <importFile
      :title="'导入'"
      :actionUrl="urls"
      :params="params"
      @close="closeHandler"
    />
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
    <!-- <el-button @click="closeDrawer(1)">关 闭</el-button>
      <multiuse-button type="primary" :click="closeDrawer.bind(this, 2)" :disabled="fileList.length<1">保 存</multiuse-button> -->
    </div>
  </div>
</template>
<script>
import {downloadUrl} from '@/utils'
import moment from 'moment'
export default {
  data(){
    return{
      urls:'/api/cmscloud.wholesales/orderGoods/productUpload',
      params:{
        // powerType:this.carData.powerType,
        dealerCode:this.carData.dealerCode,
        accountType:this.carData.accountType,
        transportType:this.carData.transportType,
        invoiceType:this.carData.invoiceType,
        isRebate:this.carData.isRebate,
        orderType:this.carData.orderType,
        orderDetailType:this.carData.orderDetailType,
      }
    }
  },
  props:['carData'],
  created(){
    console.log("carData=====created",this.carData)
  },
  methods:{
    closeDrawer(type){
      this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
          confirmButtonText: '下载',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {

          downloadUrl('https://bjev-cms-oss-public.oss-cn-beijing.aliyuncs.com/产品导入.xlsx','产品导入');

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
    },
    closeHandler(val){
      console.log(val,'val')
      if(val&&val.length>0){
        if(val[0].url.result=="success"){
          this.$emit('close',val[0].url.resultList)
        }else{
          this.$emit('close',[])
        }
      }else{
        this.$emit('close',[])
      }
    },


  },
}

</script>
